popover: Fix repositioning logic
authorMatthias Clasen <mclasen@redhat.com>
Wed, 29 Apr 2020 03:26:19 +0000 (23:26 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 29 Apr 2020 03:26:19 +0000 (23:26 -0400)
When the arrow changes position, we need to queue
an allocation to ensure that gtk_widget_allocate
actually calls our ->size_allocate vfunc.

gtk/gtkpopover.c

index 7de2713771ddef5f58cf48c245547019d9f456d8..70a15ea3d9fea92b89c32e69345f31ed18045fd4 100644 (file)
@@ -357,6 +357,7 @@ update_popover_layout (GtkPopover     *popover,
   gboolean flipped_x;
   gboolean flipped_y;
   GdkPopup *popup = GDK_POPUP (priv->surface);
+  GtkPositionType position;
 
   g_clear_pointer (&priv->layout, gdk_popup_layout_unref);
   priv->layout = layout;
@@ -381,6 +382,8 @@ update_popover_layout (GtkPopover     *popover,
 
   priv->final_rect = final_rect;
 
+  position = priv->final_position;
+
   switch (priv->position)
     {
     case GTK_POS_LEFT:
@@ -400,6 +403,9 @@ update_popover_layout (GtkPopover     *popover,
       break;
     }
 
+  if (priv->final_position != position)
+    gtk_widget_queue_allocate (GTK_WIDGET (popover));
+
   gtk_widget_allocate (GTK_WIDGET (popover),
                        gdk_surface_get_width (priv->surface),
                        gdk_surface_get_height (priv->surface),